package controller;

import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import pojo.Merchant;
import pojo.Order;
import service.CommentService;

@Controller
public class CommentController {
	
	@Resource(name="commentServiceImpl")
	private CommentService manager;
	
	@RequestMapping(value="/views/comments",method=RequestMethod.GET)
    public String comment(HttpSession session,Model model) {
    	model.addAttribute("merchant", session.getAttribute("user"));
    	return "WEB-INF/comment/commentList";
    }
	
	@ResponseBody
	@RequestMapping(value = "replyComment", method = RequestMethod.POST)
	public String  replyComment(String comment, String o_id){
		boolean reply_result = manager.replyComment(comment, o_id);
		System.out.println(comment+"...."+o_id);
		
		if(reply_result == true)
				return "success";
		else{
			return "failed";
		}
	}
}
